package com.qf.contorller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.service.StorageService;
import com.qf.utils.R;
import com.qf.vo.StorageVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zdl
 * @date 2025/2/15
 */
@RestController
@RequestMapping("/storage")
public class StorageController {
    @Resource
    private StorageService storageService;

    @GetMapping("/all")
    public R<PageInfo<StorageVo>> findAllStorage(@RequestParam int pageNum,@RequestParam int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<StorageVo> allStorage = storageService.findAllStorage();
        PageInfo<StorageVo> storageVoPageInfo = new PageInfo<>(allStorage);
        return R.ok(storageVoPageInfo);
    }

    @GetMapping("/del/{sid}")
    public R<Integer> delStorageBySid(@PathVariable("sid") int sid){
        return R.ok(storageService.delStorageBySid(sid));
    }
}
